 <?php include('session.php'); include('MatarSessionInactiva.php');?>
<!doctype html>
<html lang="es">
  <head>
    
    <title>Horarios</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <script src="js/bootstrap.min.js"></script>  
    <script type="text/javascript" src="js/JQuery.js"></script>
    <script type="text/javascript" src="js/insert.js"></script>
    <script type="text/javascript" src="js/cargaacademica.js"></script>
  </head>
  <body>
           <ul class="nav navbar-nav">
             <li><a href="Horarios3.php">Volver a Carreras</a></li>
           </ul>
            
           <table class='table'>
                <thead>
                  <tr>
                    <th>Codigo Curso</th>
                    <th>Nombre Curso</th>
                    <th>Grado</th>
                    <th>Profesor</th>
                    <th></th>
                    <th>Dia</th>
                    <th>Hora</th>
                    <th>Aula</th>
                    <th>Grupo</th>
                    <th>Ciclo</th>
                  </tr>
                </thead>

    <?php
    include('../Model/ModelConexion.php');
    $idcarrera=$_GET['idcarrera'];
    $conexion = new Conexion();
    
    if (substr($idcarrera, -1) == 0)//preguntamos si el valor del dato parasito.
    {
      $id = substr($idcarrera, 0, - 1);//desparacitamos el parametro, para obtener el valor de la carrera
       
          $consulta_all_carr = $conexion->Consulta("
        SELECT pcdatos.codigo as codcurso,
        pcdatos.nombre as nomcurso, 
        gradosacademicos.nombre nomgrado        
        FROM pcdatos,gradosacademicos,carreras
        WHERE gradosacademicos.codigoCarr=carreras.codigo
        AND gradosacademicos.codigoGrado=pcdatos.codigoGrado
        AND carreras.codigo= '$id'
        ORDER BY gradosacademicos.codigoGrado 
            ");

                $numero=0; 
                  
                while($fila=$conexion->Arreglo($consulta_all_carr))
                {
                  $numero++;
                  //onsubmit="return validacion();  action="../Control/Horarios.php"" onsubmit="enviarDatosCargaAcademica(); return true"
                   ?><tr><?php
                  ?>
                <div id="resultado"></div>
                <form method="POST" action="../Control/CAcademica.php" id="frm_ca" name="frm_ca">
                  <?php                 
                 // echo "<tr>";
                    echo"<td><input type='text' id='v_cod_curso' name='codigo_curso' class='form-control input-sm' value=".$fila['codcurso']." readonly></td>";
                    echo"<td>".$fila['nomcurso']."</td>";
                    echo"<td>".$fila['nomgrado']."</td>";
                    echo"<td><input required type='text' name='cedula' id='v_cedula' class='form-control input-sm' id='cedula' placeholder='Profesor'/>
            <td><a data-target='#' data-toggle='modal' class='glyphicon glyphicon-filter'></a></td> 
                </td>";

                    echo"<td>
                    <select required class='form-control' id='V_dia' name='dia'>
                          <option value=0>Seleccione</option>
                          <option>Lunes</option>
                          <option>Martes</option>
                          <option>Miercoles</option>
                          <option>Jueves</option>
                          <option>Viernes</option>
                          <option>Sabado</option>
                        </select></td>";

                    echo "<td>
            <select required class='form-control' id='V_hora' name='hora'>
                   <option value=0>Seleccione</option>
                <option value='7'>7:00 </option>
                <option value='8'>8:00 </option>
                <option value='9'>9:00 </option>
                <option value='10'>10:00 </option>
                <option value='11'>11:00 </option>
                <option value='13'>13:00 </option>
                <option value='14'>14:30 </option>
                <option value='15'>15:00 </option>
                <option value='16'>16:00 </option>
                <option value='17'>17:00 </option>
                <option value='18'>18:00 </option>
            </select>
                    </td>";

                          echo "<td>
            <select required class='form-control' id='V_aula' name='aula'>
                <option value='0'>Seleccione </option>
                <option value='1'>1 </option>
                <option value='2'>2 </option>
                <option value='3'>3 </option>
                <option value='4'>4 </option>
                <option value='5'>5 </option>
                <option value='6'>6 </option>
                <option value='7'>7 </option>
                <option value='8'>8 </option>
                <option value='9'>9 </option>
                <option value='10'>10 </option>
                <option value='11'>Lab 1</option>
                <option value='12'>Lab 2</option>
                <option value='13'>Lab 3</option>
                <option value='14'>Lab Idiomas</option>
            </select>
                    </td>";

                         echo "<td>
           <input required type='text' name='grupo' id='v_grupo' size='3' class='form-control input-sm'/>
                    </td>";
                    //consulta para ciclo
          $consulta_ciclo = $conexion->Consulta("
           SELECT caencabezado.anno as an,
            caencabezado.codigoHorario as cod,
            caencabezado.periodo as per
            FROM caencabezado
            ORDER BY caencabezado.anno
          "); 
                    //consulta para ciclo?>
            <td>
            <select name='V_codigo_ca' id='codigo_ca' class='form-control input-sm'>
              <option value="0">Seleccione</option>
              <?php while($ciclo_Array=$conexion->Arreglo($consulta_ciclo)){?>
                <option value="<?php echo $ciclo_Array['cod']?>"><?php echo $ciclo_Array['an'].' - '.$ciclo_Array['per']?></option>
              <?php }?>   
            </select>  
            </td>          

            <td><button type="submit" class="btn btn-primary" title="Aceptar" name="ca_det_Crear1">
              <span class='glyphicon glyphicon-ok'></span> 
            </button>
                         
            </td>
          </form>
                  <?php
                   
                }//while

    }
    elseif (substr($idcarrera, -1) == 1) 
    {
      $id = substr ($idcarrera, 0, - 1);
        $consulta_only_first = $conexion->Consulta("
        SELECT pcdatos.codigo AS codcurso,
        pcdatos.nombre AS nomcurso, 
        gradosacademicos.nombre nomgrado   
        FROM pcdatos,gradosacademicos,carreras
        WHERE carreras.codigo=gradosacademicos.codigoCarr
        AND gradosacademicos.codigoGrado=pcdatos.codigoGrado
        AND MOD(pcdatos.semestre,2) <> 0
        AND carreras.codigo='$id'
        ORDER BY pcdatos.semestre ASC
            "); 

          
                $numero=0; 
                
                while($fila=$conexion->Arreglo($consulta_only_first))
                {
                  $numero++;
                   ?>
          <form action="../Control/Horarios.php" method="POST" name="formhorario">    
                  <?php
                  echo "<tr>";  
                  echo"<td><input type='text' name='V_codigo_curso' class='form-control input-sm' value=".$fila['codcurso']." readonly></td>";
                    echo"<td>".$fila['nomcurso']."</td>";
                    echo"<td>".$fila['nomgrado']."</td>";
                    echo"<td> 
                    <input required type='text' name='V_cedula' id='cedula1' class='form-control input-sm'  placeholder='Profesor'/>
          <td><a data-target='#' data-toggle='modal' class='glyphicon glyphicon-filter'></a></td> 
                </td>";

                    echo"<td>
                    <select class='form-control' id='dia' name='V_dia'>
                          <option value=0>Seleccione</option>
                          <option>Lunes</option>
                          <option>Martes</option>
                          <option>Miercoles</option>
                          <option>Jueves</option>
                          <option>Viernes</option>
                          <option>Sabado</option>
                        </select></td>";

                    echo "<td>
            <select class='form-control' id='hora' name='V_hora'>
                <option value=0>Seleccione</option>
                <option value='7'>7:00 </option>
                <option value='8'>8:00 </option>
                <option value='9'>9:00 </option>
                <option value='10'>10:00 </option>
                <option value='11'>11:00 </option>
                <option value='13'>13:00 </option>
                <option value='14'>14:30 </option>
                <option value='15'>15:00 </option>
                <option value='16'>16:00 </option>
                <option value='17'>17:00 </option>
                <option value='18'>18:00 </option>
            </select>
                    </td>";

                    echo "<td>
            <select class='form-control' id='hora' name='V_aula'>
                <option value=0>Seleccione</option>
                <option value='1'>1 </option>
                <option value='2'>2 </option>
                <option value='3'>3 </option>
                <option value='4'>4 </option>
                <option value='5'>5 </option>
                <option value='6'>6 </option>
                <option value='7'>7 </option>
                <option value='8'>8 </option>
                <option value='9'>9 </option>
                <option value='10'>10 </option>
            </select>
                    </td>";

                    echo "<td>
           <input type='text' name='V_grupo' class='form-control input-sm' id=''/>
                    </td>";
                  echo "<td>
           <input type='text' name='V_codigo_ca' class='form-control input-sm'  placeholder='' />
                    </td>";
                  
                  ?>
                  <td><button type="submit" class="btn btn-primary" name="ca_det_Crear2"  title="Aceptar">
                          <span class='glyphicon glyphicon-ok'></span> 
                        </button></td>
          </form>
                  <?php
                   echo "</tr>";
                }//while_only_first

                

                  
    }//else_if
    if (substr($idcarrera, -1) == 2) 
    {
      $id = substr ($idcarrera, 0, - 1);
      $consulta_only_2 = $conexion->Consulta("
        SELECT pcdatos.codigo AS codcurso,
        pcdatos.nombre AS nomcurso, 
        gradosacademicos.nombre nomgrado   
        FROM pcdatos,gradosacademicos,carreras
        WHERE carreras.codigo=gradosacademicos.codigoCarr
        AND gradosacademicos.codigoGrado=pcdatos.codigoGrado
        AND MOD(pcdatos.semestre,2) = 0
        AND carreras.codigo='$id'
        ORDER BY gradosacademicos.`codigoGrado`
            "); 

          
                $numero=0; 
                while($fila=$conexion->Arreglo($consulta_only_2))
                {
                  $numero++;
                   
                    ?>
          <form method="POST" id="formhorario3" name="formhorario3">    
                  <?php
                  echo "<tr>";
                    echo"<td><input type='text' name='V_codigo_curso' class='form-control input-sm' value=".$fila['codcurso']." readonly></td>";
                    echo"<td>".$fila['nomcurso']."</td>";
                    echo"<td>".$fila['nomgrado']."</td>";
                    echo"<td> 
                    <input type='text' name='V_cedula' class='form-control input-sm' id='cedula' placeholder='Profesor' />
          <div id='result'></div>
                </td>";

                    echo"<td>
                    <select class='form-control' id='dia' name='V_dia'>
                          <option value=0>Seleccione</option>
                          <option>Lunes</option>
                          <option>Martes</option>
                          <option>Miercoles</option>
                          <option>Jueves</option>
                          <option>Viernes</option>
                          <option>Sabado</option>
                        </select></td>";

                    echo "<td>
            <select class='form-control' id='hora' name='V_hora'>
                   <option value=0>Seleccione</option>
                <option value='7'>7:00 </option>
                <option value='8'>8:00 </option>
                <option value='9'>9:00 </option>
                <option value='10'>10:00 </option>
                <option value='11'>11:00 </option>
                <option value='13'>13:00 </option>
                <option value='14'>14:30 </option>
                <option value='15'>15:00 </option>
                <option value='16'>16:00 </option>
                <option value='17'>17:00 </option>
                <option value='18'>18:00 </option>
            </select>
                    </td>";

                    echo "<td>
            <select class='form-control' id='hora' name='V_aula'>
                  <option value=0>Seleccione</option>
                <option value='1'>1 </option>
                <option value='2'>2 </option>
                <option value='3'>3 </option>
                <option value='4'>4 </option>
                <option value='5'>5 </option>
                <option value='6'>6 </option>
                <option value='7'>7 </option>
                <option value='8'>8 </option>
                <option value='9'>9 </option>
                <option value='10'>10 </option>
            </select>
                    </td>";

                    echo "<td>
           <input type='text' name='V_grupo' class='form-control input-sm' />
                    </td>";

                    echo "<td>
           <input type='text' name='V_codigo_ca' class='form-control input-sm'  placeholder='' />
                    </td>";
                 ?>
                  <td>
                    <button type="submit" class="btn btn-primary" name="ca_det_Crear3" id="ca_det_Crear3"  title="Aceptar">
                          <span class='glyphicon glyphicon-ok'></span> 
                    </button>
                   
                  </td>
          </form>
                  <?php
                }//while_only_2
    }//if
    ?> 

   
              </table>
  </body>
</html>

    <script type="text/javascript" language="javascript" src="js/ajax2.js"></script> 
